package com.bjpowernode.service.impl;

import com.bjpowernode.entity.Consumption;
import com.bjpowernode.mapper.ConsumptionMapper;
import com.bjpowernode.service.ConsumptionService;

import java.util.List;

public class ConsumptionServiceImpl implements ConsumptionService {

    /**
     * 访问消费类型数据
     */
    private ConsumptionMapper consumptionMapper;

    @Override
    public void insertConsumption(Consumption consumption) {
        this.consumptionMapper.insertConsumption(consumption);
    }

    @Override
    public List<Consumption> selectAllFirstConsumptions() {
        return this.consumptionMapper.selectAllFirstConsumptions();
    }

    @Override
    public void deleteConsumptionById(Integer id) {
        this.consumptionMapper.deleteConsumptionById(id);
        this.consumptionMapper.deleteConsumptionsByLevel(id);
        //由于配置文件里没有导入 Spring tx 的命名空间，所以就不配置 Spring 事务了
    }

    @Override
    public Consumption selectConsumptionById(Integer id) {
        return this.consumptionMapper.selectConsumptionById(id);
    }

    @Override
    public void updateConsumptionById(Consumption consumption) {
        this.consumptionMapper.updateConsumptionById(consumption);
    }

    public ConsumptionMapper getConsumptionMapper() {
        return consumptionMapper;
    }

    public void setConsumptionMapper(ConsumptionMapper consumptionMapper) {
        this.consumptionMapper = consumptionMapper;
    }

}
